package cn.magic.feignclient;

import cn.magic.Store;
import cn.magic.ajax.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

@Component
public class StoreFallbackFactory implements FallbackFactory<StoreFeignClient> {

    @Override
    public StoreFeignClient create(Throwable throwable) {
        return new StoreFeignClient() {
            @Override
            public AjaxResult save(@RequestBody Store store) {
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("系统繁忙，请稍后重试");
            }
        };
    }
}
